home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Development Tools & Languages / MacApp C++ Load⁄dump / DemoTextDump 1 / UDemoText.h < prev   
Encoding:
C/C++ Source or Header  |  1992-07-15  |  3.4 KB  |  116 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1989 - 1990 by Apple Computer, Inc. All rights reserved. */
  2. /* UDemoText.p */
  3.  
  4.  
  5. /*
  6.     This sample application demonstrates the breadth of alternatives
  7.     available when using the MacApp building-block "UTEView" for text-editing.
  8. */
  9.  
  10. #ifndef __DEMOTEXTDUMP__
  11. #include "DemoTextDump.h"
  12. #endif  __DEMOTEXTDUMP__
  13.  
  14.  
  15. #define qDebug TRUE
  16.  
  17. const unsigned long kSignature            = 'SS04';        /* application signature */
  18. const unsigned long kFileType            = 'TEXT';        /* file-type code for saved disk files --
  19.                                                           uses standard text files */
  20. const short kWindowRsrcID        = 1004;                    /* 'view' template for a DemoText window */
  21. const short kViewRsrcID            = 1005;                    /* 'view' template for a DemoText view */
  22.  
  23.                                                         /* Additional document specifications */
  24. struct TextSpecs {
  25.     Str255 theTextFont;
  26.     Style theTextFace;
  27.     short theTextSize;
  28.     RGBColor theTextColor;
  29.     short theJustification;                                /* record justification */
  30.     RGBColor theBackColor;                                /* Window's background color */
  31. };
  32. typedef TextSpecs *TextSpecsPtr;
  33. typedef TextSpecsPtr *TextSpecsHdl;
  34.  
  35. class TDemoTextApplication : public TApplication {
  36.   public:
  37.  
  38.     virtual pascal void IDemoTextApplication(void);
  39.                 /* Initialize the Application */
  40.  
  41.     virtual pascal TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
  42.                 /* Launches a TTextDocument */
  43.  
  44. #if  qDebug
  45.     virtual pascal void IdentifySoftware(void);
  46. #endif
  47.  
  48. };
  49.  
  50. class TTextDocument : public TDocument {
  51.   public:
  52.  
  53.     Handle fDocText;                                    /* The text owned by the document */
  54.     TEStyleHandle fStyles;                                /* Style handle, if any */
  55.     STHandle fElements;                                    /* Handle to element array, if any */
  56.     TTEView *fTEView;                                    /* The view which displays the text */
  57.  
  58.     TextSpecs fTextSpecs;                                /* Specifies properties of the text */
  59.  
  60.                         /* Initialization and freeing */
  61.  
  62.     virtual pascal void ITextDocument(void);
  63.     virtual pascal void Free(void);
  64.     virtual pascal void DoInitialState(void);
  65.     virtual pascal void FreeData(void);
  66.  
  67.                         /* Filing */
  68.  
  69.     virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
  70.     virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
  71.     virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
  72.  
  73.                         /* Making views and windows */
  74.  
  75.     virtual pascal void DoMakeViews(Boolean forPrinting);
  76.  
  77.                         /* Command processing */
  78.  
  79.     virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
  80.     virtual pascal void DoSetupMenus(void);
  81.  
  82.                         /* Auxiliary routines */
  83.  
  84.     virtual pascal void ChangeBackColor(RGBColor *newColor);
  85.  
  86.     virtual pascal void SetSpecStyle(void);
  87.  
  88.     virtual pascal void ShowReverted(void);
  89.                 /* When the user reverts a document, this is called after reading
  90.                   the old document and before displaying it. Causes the reverted
  91.                   font specs to be installed. */
  92.  
  93.                 /* Debugging */
  94.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  95.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  96.  
  97. };
  98.  
  99. class TJustCommand : public TCommand {
  100.   public:
  101.     TTEView *fTEView;
  102.     short fOldJust;
  103.     short fNewJust;
  104.  
  105.     virtual pascal void IJustCommand(TTEView *itsTEView, short itsNewJust);
  106.  
  107.     virtual pascal void DoIt(void);
  108.  
  109.     virtual pascal void RedoIt(void);
  110.  
  111.     virtual pascal void UndoIt(void);
  112.  
  113.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  114.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  115. };
  116.